package com.lighting.common.dubbo.filter;

import com.lighting.common.core.util.JsonUtil;
import com.lighting.common.log.TraceConstant;
import com.lighting.common.log.TraceUtils;
import org.apache.dubbo.common.constants.CommonConstants;
import org.apache.dubbo.common.extension.Activate;
import org.apache.dubbo.rpc.*;

@Activate(group = CommonConstants.CONSUMER)
public class ConsumerFilter implements Filter {

    @Override
    public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException {
        invocation.setAttachment(TraceConstant.TRACE_INFO, JsonUtil.toJSONString(TraceUtils.getTraceBuilder()));
        return invoker.invoke(invocation);
    }
}
